package co.yixiang.yshop.module.tables.dal.mysql.reservation;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.tables.dal.dataobject.reservation.ReservationDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.tables.controller.admin.reservation.vo.*;

/**
 * 预约记录 Mapper
 *
 * @author yshop
 */
@Mapper
public interface ReservationMapper extends BaseMapperX<ReservationDO> {

    default PageResult<ReservationDO> selectPage(ReservationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReservationDO>()
                .eqIfPresent(ReservationDO::getTableId, reqVO.getTableId())
                .likeIfPresent(ReservationDO::getCustomerName, reqVO.getCustomerName())
                .eqIfPresent(ReservationDO::getContactNumber, reqVO.getContactNumber())
                .betweenIfPresent(ReservationDO::getReservationTime, reqVO.getReservationTime())
                .eqIfPresent(ReservationDO::getNumberOfGuests, reqVO.getNumberOfGuests())
                .eqIfPresent(ReservationDO::getReservationStatus, reqVO.getReservationStatus())
                .eqIfPresent(ReservationDO::getPaymentStatus, reqVO.getPaymentStatus())
                .eqIfPresent(ReservationDO::getNotes, reqVO.getNotes())
                .betweenIfPresent(ReservationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReservationDO::getId));
    }

    default List<ReservationDO> selectList(ReservationExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ReservationDO>()
                .eqIfPresent(ReservationDO::getTableId, reqVO.getTableId())
                .likeIfPresent(ReservationDO::getCustomerName, reqVO.getCustomerName())
                .eqIfPresent(ReservationDO::getContactNumber, reqVO.getContactNumber())
                .betweenIfPresent(ReservationDO::getReservationTime, reqVO.getReservationTime())
                .eqIfPresent(ReservationDO::getNumberOfGuests, reqVO.getNumberOfGuests())
                .eqIfPresent(ReservationDO::getReservationStatus, reqVO.getReservationStatus())
                .eqIfPresent(ReservationDO::getPaymentStatus, reqVO.getPaymentStatus())
                .eqIfPresent(ReservationDO::getNotes, reqVO.getNotes())
                .betweenIfPresent(ReservationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ReservationDO::getId));
    }

}
